<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 使用工厂类来创建对象
      //   var person = new Object();
      //   person.name = "鸣人";
      //   person.sex = "男";
      //   person.age = 19;
      //   person.skill = function () {
      //     return person.name + "分身术";
      //   };
      //   console.log(
      //     person.name + ":" + person.sex + ":" + person.age + ":" + person.skill()
      //   );

      function person(name, sex, age, skill) {
        var obj = new Object();
        obj.name = name;
        obj.sex = sex;
        obj.age = age;
        obj.skill = function () {
          return skill;
        };

        return obj;
      }

      var a = person("鸣人", "男", "18", "分身术");
      var b = person("佐佐助", "男", "28", "千鸟");
      console.log(a);
      console.log(b);
      console.log(a.skill());
    </script>
  </body>
</html>
